#include "../logs/qywlog.h"

  void test_log()
  {  
    // 自定义日志器输出
    //qywlog::Logger::ptr logger = qywlog::LoggerManager::getInstance().getLogger("async_logger");
    //logger->debug("%s", "测试日志");
    //logger->info("%s", "测试日志");
    //logger->warn("%s", "测试日志");
    //logger->error("%s", "测试日志");
    //logger->fatal("%s", "测试日志");
    //size_t count = 0;
    //while(count < 500000)
    //{
    //  logger->fatal("测试日志-%d", count++);
    //}
    // 默认root日志器输出
    DEBUG("%s", "测试日志");
    INFO("%s", "测试日志");
    WARN("%s", "测试日志");
    ERROR("%s", "测试日志");
    FATAL("%s", "测试日志");
    size_t count = 0;
    while(count < 500000)
    {
      FATAL("测试日志-%d", count++);
    }
    
  }

int main()
{
  // 日志器模块管理器测试 + 全局单例模式下日志器的建造者
  std::unique_ptr<qywlog::LoggerBuilder> builder(new qywlog::GlobalLoggerBuilder());
  builder->buildLoggerName("async_logger");
  builder->buildLoggerLevel(qywlog::LogLevel::value::WARN);
  builder->buildFormatter("[%c][%f:%l]%m%n");
  builder->buildLoggerType(qywlog::LoggerType::LOGGER_ASYNC);
  builder->buildEnableUnSageAsync();
  builder->buildSink<qywlog::FileSink>("./logfile/async.log");
  builder->buildSink<qywlog::StdoutSink>();
  builder->build();
  test_log();

  return 0;
}
